package com.werdior.weixinbackend.config;

import com.github.sd4324530.fastweixin.api.UserAPI;
import com.github.sd4324530.fastweixin.api.config.ApiConfig;
import com.werdior.weixinbackend.Handle.TestConfigChangeHandle;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by weirdor on 2017/12/26.
 */
@Configuration
public class WeChatConfig {
    @Value("${wx.appId}")
    private String appid;

    @Value("${wx.appsecret}")
    private String appsecret;

    @Bean
    public ApiConfig apiConfig(){
        ApiConfig apiConfig=new ApiConfig(appid,appsecret);
        TestConfigChangeHandle configChangeHandle = new TestConfigChangeHandle();
        apiConfig.addHandle(configChangeHandle);
        return  apiConfig;
    }

    @Bean
    public UserAPI userAPI(){
        UserAPI userAPI = new UserAPI(apiConfig());
        return userAPI;
    }

}
